package org.box.metadata.shell.console;

import org.box.metadata.cli.util.HelpFormatter;
import org.box.metadata.shell.CommandHandler;
import org.box.metadata.shell.Shell;
import org.box.metadata.shell.exception.TerminatedException;
import org.box.metadata.shell.exception.ValidationException;

/**
 * Prints a list of available applications and commands
 * 
 * @author <a href="mailto:alexander.box@gmail.com">Alexander Korobka</a>
 * 
 */
public class HelpCommandHandler implements CommandHandler<ConsoleDefaultConfiguration> {

	private static final String ALLICATION_LIST_MSG = "A list of the following commands are avaliable:\n";

	public void validate(ConsoleDefaultConfiguration cfg, Shell shell) throws ValidationException {
	}

	public void process(ConsoleDefaultConfiguration cfg, Shell shell) throws TerminatedException {
		HelpFormatter formatter = new HelpFormatter(shell.getCfgClasses());

		formatter.printHelp(ALLICATION_LIST_MSG, shell.getCommands());
	}

}